package com.example.spinning.service;

import com.example.spinning.bean.DailyReport;
import com.example.spinning.bean.YearlyReport;
import com.example.spinning.mapper.YearlyReportMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.util.List;


@Service
@Transactional
public class YearlyReportService {
    @Autowired
    YearlyReportMapper yearlyReportMapper;



    //增加操作
    public int addNewYearlyReport(YearlyReport yearlyReport) {
        //monthlyReport.setDate(new Timestamp(System.currentTimeMillis()));
        return yearlyReportMapper.addNewYearlyReport(yearlyReport);
    }

    //删除操作
    public boolean deleteYearlyReportById(Long[] ids) {
        int result = yearlyReportMapper.deleteYearlyReportById(ids);
        return result == ids.length;
    }
    //查询并分页
    public PageInfo<YearlyReport> findPage(Integer page, Integer size,String workshop,String year) {

        YearlyReport yearlyReport = new YearlyReport();
        yearlyReport.setWorkshop(workshop);
        yearlyReport.setYear(year);

        PageHelper.startPage(page,size);
        List<YearlyReport> list = yearlyReportMapper.select(yearlyReport);
        PageInfo<YearlyReport> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }
    //动态修改
    public int  updateCategoryById(YearlyReport yearlyReport){
        int result = yearlyReportMapper.updateByPrimaryKeySelective(yearlyReport);
        return result;
    }


}




